mod huarongdao;
pub mod hrd;
pub mod hrdbtree;
pub mod hrdhashmap;
pub use crate::huarongdao::{State, Move};


use wasm_bindgen::prelude::wasm_bindgen;
// use wasm_bindgen::JsValue;
#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(js_namespace = console)]
    fn log(s: &str);
}

#[wasm_bindgen]
pub fn query(input: u32) -> Vec<u8> {
    let state = hrdhashmap::State::from_u32(input);
    let res = state.query_move();
    if let Ok(res) = res {
        res
    } else {
        vec![]  
    }
}

#[wasm_bindgen]
pub fn one_step(input: u32) -> Vec<u8> {
    let state = hrdhashmap::State::from_u32(input);
    let res = state.query_move();
    if let Ok(res) = res {
        res
    } else {
        vec![]  
    }
}

#[wasm_bindgen]
pub fn answer(input: u32) -> Vec<u32> {
    let state = hrdhashmap::State::from_u32(input);
    state.search().into_iter().map(|x| x.0).collect()
}
